package com.load.objects;

import java.util.*;

public class ClassWrapper {

	private Integer id;
	
	private double constantineCohesion = 0.0;

	private List<String> fields = new ArrayList<String>();

	private List<MethodWrapper> methods = new ArrayList<MethodWrapper>();
	
	public ClassWrapper(Integer id) {
		this.id = id;
	}

	public ClassWrapper(Integer id, List<String> fields, List<MethodWrapper> methods) {
		this.id = id;
		this.fields = fields;
		this.methods = methods;
	}

	public Integer getId() {
		return id;
	}
	
	public double getConstantineCohesion() {
		return constantineCohesion;
	}
	
	public void setConstantineCohesion(double constantineCohesion) {
		this.constantineCohesion = constantineCohesion;
	}

	public List<String> getFields() {
		return fields;
	}

	public void setFields(List<String> fields) {
		this.fields = fields;
	}

	public List<MethodWrapper> getMethods() {
		return methods;
	}

	public void setMethods(List<MethodWrapper> methods) {
		this.methods = methods;
	}

	public int getNumFields() {
		return fields.size();
	}

	public int getNumberMethods() {
		return methods.size();
	}

	public int getNumMethodsAccessField(String field) {
		return getMethodsAccessField(field).size();
	}

	private List<MethodWrapper> getMethodsAccessField(String field) {
		List<MethodWrapper> methodsAccess = new ArrayList<MethodWrapper>();
		for (MethodWrapper method : methods) {
			if (method.accessField(field)) {
				methodsAccess.add(method);
			}
		}
		return methodsAccess;
	}

	@Override
	public String toString() {
		return "ClassWrapper [id=" + id + ", fields=" + fields + ", methods=" + methods + "]";
	}

}